
  <template>
  	<div class="index">

  		<div class="center">
  			<left></left>
  			<div class="right">
            <top></top>
            <div class="hei10"></div>

            <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">
              当前位置：
              <router-link to="/index" style="color: #409eff;">分销后台</router-link>>
              <router-link to="/productionBasismanag" style="color: #409eff;">产品渠道管理</router-link>>
              产品详情
            </div>

            <div class="hei10"></div>
            <div class="addpro">
                    <div v-loading = "loading">
                        <div class="step">
                            <div class="con">
                                <div class="shop-title">{{form.name}}产品详情</div>
                                <div class="shop-time">
                                  <template v-if="form.operationUser">
                                	操作人：<span>{{form.operationUser}}</span>
                                  </template>
                                	最后修改日期：<span>{{form.updated_at}}</span>
                                  <template v-if="versionlist.length > 0">
                                  历史版本：<el-select v-model="version" placeholder="请选择历史版本" @change="changeVersion" clearable>
                                              <el-option v-for="item in versionlist" :key="item.id" :label="item.title" :value="item.id"></el-option>
                                          </el-select>
                                  </template>
                                </div>
                                <el-form ref="form" :rules="rules" @submit.native.prevent :model="form" label-width="120px">
                                    <div class="flex w330">
                                        <el-form-item label="运营商:">
                                          {{form.operator}}
                                        </el-form-item>
                                        <el-form-item label="产品类型:">
                                          {{form.plan_type_id}}
                                        </el-form-item>
                                    </div>
                                    <div class="flex w330">
                                        <el-form-item label="产品名称:">
                                          {{form.name}}
                                        </el-form-item>
                                        <el-form-item label="产品编号:">
                                          {{form.sku}}
                                        </el-form-item>
                                    </div>
                                    <el-form-item label="归属地:" class="w330">
                                      {{form.province}}-{{form.city}}
                                        <!-- <el-cascader @change="changeaddress" v-model="form.citys" :options="citylist"></el-cascader> -->
                                    </el-form-item>
                                    <el-form-item label="生产定义:">
                                        <div class="ori">
                                          <el-form-item label="是否需要身份证号码:">
                                            <div v-if="form.need_num==0">不需要</div>
                                            <div v-if="form.need_num==1">需要</div>
                                          </el-form-item>
                                          <el-form-item label="是否需要身份证照片:">
                                            <div v-if="form.real_name_type==0">需要</div>
                                            <div v-if="form.real_name_type==1">不需要</div>
                                          </el-form-item>
                                          <el-form-item label="生产地址:">
                                            {{form.produce_address}}
                                          </el-form-item>
                                        </div>
                                    </el-form-item>
                                    <el-form-item label="限制条件:">
                                        <div class="ori">
                                            <el-form-item label="不发货地址设置:">
                                              <div style="display: flex;flex-wrap: wrap;">
                                                  <div v-for="(item,i) in keyv"  :key="item.id" v-if="item.key2" style="border: 1px #EAEAEA solid;margin: 10px 10px 0 0;padding: 8px 16px;line-height: 1">{{item.key2}}-{{item.key3}}</div>
                                              </div>
                                                <!-- <el-button type="primary"  size="mini" plain @click="keylog = true">已设置{{mingan.citys.length}}个</el-button> -->
                                            </el-form-item>
											<el-form-item label="按身份证号前4位识别:">
                                              <div style="display: flex;flex-wrap: wrap;">
                                                  <div v-if="form.is_identify_id==1">是</div>
                                                  <div v-if="form.is_identify_id==0">否</div>
                                              </div>
                                                <!-- <el-button type="primary"  size="mini" plain @click="keylog = true">已设置{{mingan.citys.length}}个</el-button> -->
                                            </el-form-item>
											<el-form-item label="已设置号码:">
                                              <div style="display: flex;flex-wrap: wrap;">
												<el-tag
													style="margin-right: 10px;
													"
													v-for="tag in tags"
													:key="tag.name"
													size="small"
													type="">
													{{tag.name}}
												</el-tag>
                                              </div>
                                                <!-- <el-button type="primary"  size="mini" plain @click="keylog = true">已设置{{mingan.citys.length}}个</el-button> -->
                                            </el-form-item>
                                            <el-form-item class="age" label="年龄限制(周岁):">
                                              {{form.min_age}} - {{form.max_age}}
                                            </el-form-item>
                                            <div class="xiaoming">
												<el-form-item label="单人开卡数量限制:">
                          <div v-if="form.max_purchase == -1">不限制</div>
                          <div v-if="form.max_purchase == 1">1</div>
                          <div v-if="form.max_purchase == 2">2</div>
                          <div v-if="form.max_purchase == 3">3</div>
                          <div v-if="form.max_purchase == 4">4</div>
                          <div v-if="form.max_purchase == 5">5</div>
												</el-form-item>

												<!-- 小鸣莺专用 -->
												<el-form-item label="检测周期:">
                          <div v-if="xiaomingtime == 0">不限制</div>
                          <div v-if="xiaomingtime == 1">1个月</div>
                          <div v-if="xiaomingtime == 2">2个月</div>
                          <div v-if="xiaomingtime == 3">3个月</div>
                          <div v-if="xiaomingtime == 4">4个月</div>
                          <div v-if="xiaomingtime == 5">5个月</div>
                          <div v-if="xiaomingtime == 6">6个月</div>
                          <div v-if="xiaomingtime == 7">7个月</div>
                          <div v-if="xiaomingtime == 8">8个月</div>
                          <div v-if="xiaomingtime == 9">9个月</div>
                          <div v-if="xiaomingtime == 10">10个月</div>
                          <div v-if="xiaomingtime == 11">11个月</div>
                          <div v-if="xiaomingtime == 12">12个月</div>
												</el-form-item>
											</div>
                      </div>
                  </el-form-item>
									<div class="flex">
										<div class="flex">
											<el-form-item label="设置库存:"  class="kucunset">
                        <div v-if="form.is_stock == 0">不限制</div>
                        <div v-if="form.is_stock == 1">{{form.stock}}</div>
											</el-form-item>
											<el-form-item label="库存报警:" v-if="form.is_stock == 1">
                        {{form.warn_stock}}
											</el-form-item>
										</div>
									</div>
                                  <el-form-item class="w480" label="生产备注:">
                                    {{form.produce_remark}}
                                  </el-form-item>
                                  <el-form-item class="w480" label="结算规则:">
                                    {{form.commission_rule}}
                                  </el-form-item>
                                  <!-- <el-form-item label="物流公司:">
                                      <el-select v-model="form.tracking_company_id" placeholder="物流公司:">
                                        <el-option v-for="item in tracklist" :key="item.id" :label="item.company" :value="item.id"></el-option>
                                      </el-select>
                                  </el-form-item> -->
                              </el-form>
                          </div>
                        </div>

                        <div class="step">
                            <div class="tilte">关联号池设置</div>
                            <div class="con haochi">
                                <el-form ref="form" @submit.native.prevent :model="form" label-width="80px">
                                    <el-form-item>
                                        <div class="flex" v-if="pool==1" style="margin-bottom: 30px;">
                                          <div>关联号库（提供选号）：</div>
                                          <div>{{form.pool_id}}</div>
                                        </div>
                                        <div class="flex" v-if="pool==2">
                                          <div>无（不提供选号）</div>
                                        </div>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>

                    </div>
				</div>
			</div>
		</div>

		<!-- <foot></foot> -->
	</div>
</template>

<script>
	import { provinceAndCityData, CodeToText, TextToCode } from 'element-china-area-data'
	import UploadExcelComponent from "@/components/UploadExcel/index.vue";
	import E from 'wangeditor'
	import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	import foot from '@/components/foot.vue'
	export default{
		components: {
			"left": left,
			"top": top,
			"foot": foot,
			UploadExcelComponent
		},
		name: 'myDistributor',
		data(){
			return{
				taglog:false,
				taglist:['类型1','类型2'],
				inputVisible: false,
				inputValue: '',

                keylog:false,
                keyv:[
                    {"key1":"","key2":"","key3":""}
                ],

				mingan:{
					city:"",
					citys:"",
					fixcitys:""
				},
				randomnum:"",
                jingdongrandom:"",
				search:"",
				msg:"hello",
				log:false,
				loading:true,

				typelist:[],
				citylist:provinceAndCityData,

				poollist:"",
                pool:"2",

                tracklist:"",
				form:{
          tracking_company_id:"",
          pool_id:"",
					produce_address:"",
					operator:"",
					name:"",
					sku:"",
					plan_type_id:"",
					province:"",
					city:[],
					citys:[],
					real_name_type:'0',
					produce_remark:"",
					status:"",
					comname:"",
					min_age:"",
					max_age:"",
					max_purchase:"-1",
					need_num:"0",

					haochinum:1,
					haochival:1,

					address_province:"",
					address_city:"",
					address_district:"",
					commission_rule:"",

					stock:"",
					is_stock:"0",
					warn_stock:"",
					is_identify_id:0,
					id_identify:[]
				},

                rules: {
                  operator: [{ required: true, message: '必选', trigger: 'change' }],
                  name: [{ required: true, message: '必填', trigger: 'blur' }],
                  sku: [{ required: true, message: '必填', trigger: 'blur' }],
                  city: [{ required: true, message: '请选择活动区域', trigger: 'change' }],
                  real_name_type: [{ required: true, message: '请输入', trigger: 'change' }],
                  randomnum: [{ required: true, message: '请输入抓单码', trigger: 'change' }],
                  title: [{ required: true, message: '必填', trigger: 'change' }],
                  is_need_photo: [{ required: true, message: '必选', trigger: 'change' }],
                  img: [{ required: true, message: '必选', trigger: 'change' }],
                  edit: [{ required: true, message: '必填', trigger: 'change' }],
                  visible: [{ required: true, message: '必选', trigger: 'change' }],
                  commission: [{ required: true, message: '必选', trigger: 'change' }],
                },
                abstract:"",
				moneyform:{
					order_page_id:"",
					visible:'1',
					commission:0,
					child_shop_ids:"",
					dislist:"",
					money:"",
					list:""
				},
				kejian:false,
				sub1:true,
				sub2:true,
				sub3:false,
                sub4:true,
				showmoney:false,
				sanlist:[
					// {name:"中国联通",id:10010},
					// {name:"中国移动",id:10086},
					// {name:"中国电信",id:10000},
					{name:"中国广电",id:10099}
				],
                randomvalue:"",
                randomone:false,
                randomlog:false,
                shop_id:"",
                statusshop:false,
				url:"",

				xiaomingtime:"",
				xiaomingying:"",
				fx:true,
				fxs:{
					id:"",
					id_card:"",
					id_card_range:"",
					address_mobile:"",
					address_mobile_range:"",
					address:"",
					address_range:"",
					type:"",
					status:""
				},
				fxsid:"",
				fxsidsave:"",
				fxloading:true,

				kucuninp:false,

        version: '',
        versionlist: [],
		tags: [],
			}
		},
		created() {
            //地址配置,用于下载模板
            if(window.location.href.indexOf("91haoka_platform") > -1){
            	console.log("线上项目，谨慎操作。")
            	this.url = window.location.origin+"/91haoka_platform/"
            }else{
            	this.url = ""
			}
			//获取类型
			this.getproductstype();
			this.getlists()
			this.getprodetail()
			//小鸣莺家用
			var xiaomingying = JSON.parse(localStorage.getItem('USER'));
			this.xiaomingying = xiaomingying.id
            //获取56
            this.gettracklist()

			//随机生成10位数
            axios.get('/api/gth/user/shop')
                .then(response => {
                    if(response.data.msg.code == 0){
                        this.shop_id = response.data.data.shop_id
                    }else{
                        if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
                        that.$message.error(response.data.msg.info);
                    }
				})


		},

		methods:{
      //选择版本
      changeVersion(id){
        var flag = ''
        this.loading = true
        if(id){
          flag = 2
        }
        else{
          flag = 1
        }
        let data = {
          id: id,
          flag: flag
        }
        //产品详情
        this.getprodetail(data)
      },
			//库存选择与显示
			changekucun:function(){
				if(this.form.is_stock == 1){
					this.kucuninp = true
				}else{
					this.kucuninp = false
					this.form.stock = ""
					this.form.warn_stock = ""
				}
			},
			//更换默认和自定义
			changetype:function(type){
				this.fxs.type = type
				this.fxloading = true
				this.getfx()
			},
			//更新风险全局方案
			fixfx:function(){
				var that = this;
				if(this.fxs.type == 0){
					var sj = {
						id_card:this.fxs.id_card,
						id_card_range:this.fxs.id_card_range,
						address_mobile:this.fxs.address_mobile,
						address_mobile_range:this.fxs.address_mobile_range,
						address:this.fxs.address,
						address_range:this.fxs.address_range,
						type:this.fxs.type,
						status:this.fxs.status,
						service_id:this.fxsidsave
					}
				}else{
					var sj = {
						id_card:this.fxs.id_card,
						id_card_range:this.fxs.id_card_range,
						address_mobile:this.fxs.address_mobile,
						address_mobile_range:this.fxs.address_mobile_range,
						address:this.fxs.address,
						address_range:this.fxs.address_range,
						type:this.fxs.type,
						status:this.fxs.status,
						service_id:this.fxsid
					}
				}
				axios.post('/api/plan-market/service/update',sj)
					.then(response => {
						if(response.data.msg.code == 0){
							that.$message({
								message: '保存成功',
								type: 'success'
							});

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存风险全局方案
			savefx:function(){

				var that = this;
				var sj = {
						id_card:this.fxs.id_card,
						id_card_range:this.fxs.id_card_range,
						address_mobile:this.fxs.address_mobile,
						address_mobile_range:this.fxs.address_mobile_range,
						address:this.fxs.address,
						address_range:this.fxs.address_range,
						type:this.fxs.type,
						status:this.fxs.status
					}
				axios.post('/api/plan-market/service/create',sj)
					.then(response => {
						if(response.data.msg.code == 0){
							that.$message({
								message: '保存成功',
								type: 'success'
							});
							if(that.fxs.type == 1){
								that.fxsid = response.data.data.id
							}
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//获取风险全局方案
			getfx:function(){

				var that = this;
				if(this.fxs.type == 0){
					that.fx = true
					axios.get('/api/plan-market/service/index?type=0&service_id='+ this.fxsidsave)
						.then(response => {
							if(response.data.msg.code == 0){
								if(response.data.data == null){
									this.fxs = {
										id:"",
										id_card:"",
										id_card_range:'9999',
										address_mobile:"",
										address_mobile_range:'9999',
										address:"",
										address_range:'9999',
										type:0,
										status:""
									}
								}else{
									that.fxs = response.data.data
									that.fxsidsave = response.data.data.id
								}
							}else{
								that.$message.error(response.data.msg.info);
							}
							this.fxloading = false
						})
				}else{
					this.fx = false
					axios.get('/api/plan-market/service/index?type=1&service_id='+ this.fxsid)
						.then(response => {
							if(response.data.msg.code == 0){
								if(response.data.data == null){
									this.fxs = {
										id:"",
										id_card:"",
										id_card_range:'9999',
										address_mobile:"",
										address_mobile_range:'9999',
										address:"",
										address_range:'9999',
										type:1,
										status:""
									}
								}else{
									that.fxs = response.data.data
								}
							}else{
								that.$message.error(response.data.msg.info);
							}
							this.fxloading = false
						})
				}

			},
            //手动添加关键词
            keygo:function(){
                this.mingan.citys =[]
                this.mingan.fixcitys = []
                for(var i in this.keyv){
                    if(this.keyv[i].key1 != "" && this.keyv[i].key2 != "" && this.keyv[i].key3 != "" ){
                        this.mingan.citys.push(this.keyv[i].key1)
                        var k2 = this.keyv[i].key2
                        var k3 = this.keyv[i].key3
                        var obj={}
                        obj[k2] = k3
                        this.mingan.fixcitys.push(obj)
                    }
                }
                this.keylog = false
            },
             //删除关键词
            keydel:function(i){
                this.keyv.splice(i,1);
            },
            //增加关键词
            addkey:function(){
                this.keyv.push({"key1":"","key2":"","key3":""})
            },
            //下载
            xiazai:function(){

            	const a = document.createElement('a');
            	a.setAttribute('download', '敏感地区模板.xlsx');
            	a.setAttribute('href', this.url+'static/mingandiqu.xlsx');
            	a.click();

            },

            //获取快递公司
            gettracklist:function(){
                var that = this
                axios.get('/api/plan-market/logistics-companies')
                	.then(response => {
                		that.tracklist = response.data.data
                	})
            },
            //获取号池
            getlists:function(){
                var that = this
                axios.get('/api/plan-market/pool/list?page=1&page_size=1000&status=1')
                	.then(response => {
                		that.poollist = response.data.data.data
                	})
            },

			//获取产品详情
			getprodetail:function(data){
        if(data){
          var d = new FormData()
          d.log_id = data.id
          d.flag = data.flag
        }
				var that = this;
				axios.get('/api/plan-market/product?product_id='+this.$route.query.id, {params:d})
					.then(response => {
						if(response.data.msg.code == 0){
							that.loading = false

              that.versionlist = response.data.data.history_logs
							that.form = response.data.data
							//输入的4位身份证号
				if(that.form.id_identify.length!=0){
					for(var x = 0;x<that.form.id_identify.length;x++){
						this.tags.push({'name':that.form.id_identify[x]})
					}
				}
              for(let i in that.sanlist){
                if(that.form.operator == that.sanlist[i].id){
                  that.form.operator = that.sanlist[i].name
                  break
                }
              }
              for(let j in that.typelist){
                if(that.form.plan_type_id == that.typelist[j].id){
                  that.form.plan_type_id = that.typelist[j].name
                  break
                }
              }


                            //查看有没有号池的id  没有就是没关联
                            if(that.form.pool_id != 0){
                                that.pool = "1"
                                 for(let j in that.poollist){
                                   if(that.form.pool_id == that.poollist[j].id){
                                     that.form.pool_id = that.poollist[j].name
                                     break
                                   }
                                 }
                            }else{
                                 that.pool = "2"
                                 that.form.pool_id = ""
                            }

                            //敏感地区
							that.mingan.citys = that.form.warn_province
							that.mingan.fixcitys = that.form.warn_city

                            for( var i in that.mingan.citys){
                                that.keyv.push({"key1":"","key2":"","key3":""})

							}

                            for(var m in that.keyv){
                                that.keyv[m].key1 = that.mingan.citys[m]

                                for(var n in that.mingan.fixcitys[m]){
                                    that.keyv[m].key2 = n
                                    that.keyv[m].key3 = that.mingan.fixcitys[m][n]
                                }
                            }

							var city = []
							if(that.form.province != ""){
								try{
									city.push(TextToCode[that.form.province].code)
								}catch(err){
									console.log('没有这个地址对应的号码')
								}

							}
							if(that.form.city != ""){
								try{
									city.push(TextToCode[that.form.province][that.form.city].code)
								}catch(err){
									console.log('没有这个地址对应的号码')
								}

							}
							that.form.citys = city

							that.changekucun()

							that.xiaomingtime = response.data.data.max_purchase_time

							//获取到service_id后在获取方式
							axios.get('/api/plan-market/service/index?service_id='+ response.data.data.service_id)
								.then(response => {
									if(response.data.msg.code == 0){
										if(response.data.data == null){
											//获取默认方案
											axios.get('/api/plan-market/service/index?type=0')
												.then(response => {
													if(response.data.msg.code == 0){
														if(response.data.data == null){
															this.fxs = {
																id:"",
																id_card:"",
																id_card_range:'9999',
																address_mobile:"",
																address_mobile_range:'9999',
																address:"",
																address_range:'9999',
																type:0,
																status:""
															}
														}else{
															that.fxs = response.data.data
															that.fxsidsave = response.data.data.id
														}
													}else{
														that.$message.error(response.data.msg.info);
													}

													this.fxloading = false
												})

										}else{
											//如果是自定义就获取一下全局的方式
											if(response.data.data.type == 1){
												that.fx = false
												that.fxsid = response.data.data.id
												//获取到service_id后在获取全局方式
												axios.get('/api/plan-market/service/index?type=0')
													.then(response => {
														if(response.data.msg.code == 0){
															if(response.data.data == null){
																this.fxs = {
																	id:"",
																	id_card:"",
																	id_card_range:"",
																	address_mobile:"",
																	address_mobile_range:"",
																	address:"",
																	address_range:"",
																	type:0,
																	status:""
																}
															}else{
																that.fxsidsave = response.data.data.id
															}
														}else{
															that.$message.error(response.data.msg.info);
														}

														this.fxloading = false
													})
											}else{
												that.fx = true
											}
											that.fxs = response.data.data
											that.fxloading = false
										}

									}else{
										that.$message.error(response.data.msg.info);
									}

								})
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//产品名验证唯一性
			nijiushiwodeweiyi1:function(){
				var that = this;
				axios.get('/api/plan-market/product/name/isexist?name='+that.form.name)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub1 = true
						}else{
							this.sub1 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//产品编号验证唯一性
			nijiushiwodeweiyi2:function(){
				var that = this;
				axios.get('/api/plan-market/product/sku/isexist?sku='+this.form.sku)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub2 = true
						}else{
							this.sub2 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//商品名验证唯一性
			nijiushiwodeweiyi3:function(){
				var that = this;
				axios.get('/api/plan-market/order-page/name/isexist?title='+this.shopform.title)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub3 = true
						}else{
							this.sub3 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//身份证审核
			cardid:function(){
				this.moneyform.child_shop_ids = "";
				if(this.moneyform.visible == 3 || this.moneyform.visible == 4){this.kejian = true}
				if(this.moneyform.visible == 1 || this.moneyform.visible == 2){this.kejian = false}
			},

			//保存产品
			productsave:function(){

				if(this.sub1 == false || this.sub2 == false || this.sub4 == false || this.form.name == "" || this.form.sku == ""){
					return false
				}
				//发布还是仅保存


				if(this.form.address_province == undefined){
					this.form.address_province = this.form.province
					this.form.address_city = this.form.city
				}

				var that = this;
				if(this.fxs.type == 0){
					var formData = {
						product_id:this.$route.query.id,
						name:this.form.name,
						sku:this.form.sku,
						operator:this.form.operator,
						plan_type_id:this.form.plan_type_id,
						province:this.form.address_province,
						city:this.form.address_city,
						real_name_type:this.form.real_name_type,
						produce_remark:this.form.produce_remark,
						max_purchase:this.form.max_purchase,
						min_age:this.form.min_age,
						max_age:this.form.max_age,
						// status:this.form.status,
						produce_address:this.form.produce_address,
						commission_rule:this.form.commission_rule,
						warn_province:this.mingan.citys,
						warn_city:this.mingan.fixcitys,
						// tracking_company_id:this.form.tracking_company_id,
						abstract:this.abstract,
						need_num:this.form.need_num,
						max_purchase_time:this.xiaomingtime,
						service_id:this.fxsidsave,
						is_stock:this.form.is_stock,
						stock:this.form.stock,
						warn_stock:this.form.warn_stock
					}
				}else{
					var formData = {
						product_id:this.$route.query.id,
						name:this.form.name,
						sku:this.form.sku,
						operator:this.form.operator,
						plan_type_id:this.form.plan_type_id,
						province:this.form.address_province,
						city:this.form.address_city,
						real_name_type:this.form.real_name_type,
						produce_remark:this.form.produce_remark,
						max_purchase:this.form.max_purchase,
						min_age:this.form.min_age,
						max_age:this.form.max_age,
						// status:this.form.status,
						produce_address:this.form.produce_address,
						commission_rule:this.form.commission_rule,
						warn_province:this.mingan.citys,
						warn_city:this.mingan.fixcitys,
						// tracking_company_id:this.form.tracking_company_id,
						abstract:this.abstract,
						need_num:this.form.need_num,
						max_purchase_time:this.xiaomingtime,
						service_id:this.fxsid,
						is_stock:this.form.is_stock,
						stock:this.form.stock,
						warn_stock:this.form.warn_stock
					}
				}

                if(this.pool == 1 ){
                    formData.pool_id = this.form.pool_id
                }
				axios.post('/api/plan-market/product',formData)
					.then(response => {
						if(response.data.msg.code == 0){
						   that.$message.success("修改成功");
						   that.$router.push({
								path: '/productionBasismanag'
							})
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},


			//单个图片上传
			uploadok:function(file){
				var that = this;
				var formData = new FormData();
				formData.append("pic",file.raw);
				axios.post('/api/plan-market/order-page/upload-pic',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.shopform.image1 = response.data.data
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//选择省市区
			changeaddress:function(v){
				this.form.address_province = CodeToText[v[0]],
				this.form.address_city = CodeToText[v[1]]
			},
			//导入敏感地区
			exportData:function(data) {

				this.mingan.citys = []
				this.mingan.fixcitys = []
				for(var i = 0 ;i < data.results.length; i++){
					this.mingan.citys.push(data.results[i]['敏感地区'])

					if(data.results[i]['修改敏感地区'].indexOf(",") > -1){
						var arr = data.results[i]['修改敏感地区'].split(',')
					}
					else if(data.results[i]['修改敏感地区'].indexOf("，") > -1){
						var arr = data.results[i]['修改敏感地区'].split('，')
					}
					else{
						return false
						that.$message.error("数据出错了，请检查格式");
					}
					var obj = {}
					obj[arr[0]] = arr[1]
					this.mingan.fixcitys.push(obj)

			        var obj2 = {}
			        obj2['key1'] = data.results[i]['敏感地区']
			        obj2['key2'] = arr[0]
			        obj2['key3'] = arr[1]

			       this.keyv.push(obj2)
				}
			    console.log(this.mingan.citys)
			    console.log(this.mingan.fixcitys)
				this.$message({
				  message: '导入成功，共计'+this.mingan.citys.length+'条',
				  type: 'success'
				});
			},
			//获取产品类型
			getproductstype:function(){
				var that = this
				axios.get("/api/gth/plan-type")
				  .then(function(response) {
					  if(response.data.msg.code == 0){
					  	that.typelist = response.data.data
					  }else{
					  	that.$message.error(response.data.msg.info);
					  }

				  })
			},

			//自定义产品类型
			handleClose(tag) {
				this.taglist.splice(this.taglist.indexOf(tag), 1);
			},

			showInput() {
				this.inputVisible = true;
				this.$nextTick(_ => {
				  this.$refs.saveTagInput.$refs.input.focus();
				});
			},

			handleInputConfirm() {
				var that = this;
				var formData = new FormData();
				formData.append("name",this.inputValue);
				axios.post('/api/gth/plan-type/release',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.getproductstype();
							that.$message({
							  message: '添加成功',
							  type: 'success'
							});
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
				let inputValue = this.inputValue;
				if (inputValue) {
				  this.taglist.push(inputValue);
				}
				this.inputVisible = false;
				this.inputValue = '';
			}
		}

	}
</script>

<style lang="scss" scoped>

	.index{
    .el-message-box__wrapper{ z-index: 20000 !important;}
		.xiaoming{ display: flex;
			/deep/ .el-form-item{ flex: 1;}
		}
		// #editor{
        //     .w-e-text-container{ z-index: 1999 !important;}
        //     .w-e-menu{ z-index: 1999 !important;}
        // }

		.loglist{
			display: flex; justify-content: space-between; margin-bottom: 30px;
			.log_title{ padding: 7px 10px;}
		}
		.listl{ height: 350px; overflow: auto;
			/deep/ .el-input__inner{ border: none; text-align: center}
		}
		.list{

			display: flex; text-align: center; color: #727272; line-height: 45px; border: 1px #EAEAEA solid; margin-top: -1px;
			.th{ flex: 1; background: #F9F9F9; font-size: 14px; }
			.td{ flex: 1; font-size: 14px; border-right:1px #EAEAEA solid; }
		}
		.el-pagination{ text-align: right; margin: 20px 0}
		.el-dialog__wrapper{ z-index: 19999 !important;}
		.keyd{
		    display: flex;
		    /deep/ .is-plain{ height: 30px; line-height: 30px; padding: 0 10px; margin-left: 10px; }
		    #drop{
		    	/deep/ .el-button--primary{ background: #409EFF; border: 1px #409eff solid; height: 30px; line-height: 30px; padding: 0 20px;}
		    }
		}
		.protag{
			/deep/ .el-tag{ margin-right: 20px; margin-bottom: 20px;}
		}
		.addpro{

			/deep/ .el-steps{ width: 100%;  padding: 30px;}
			.kucunset{ width: 300px;}
			.kucuninp{ margin-left: 10px; margin-top: 2px;}
			.step{ margin-bottom: 20px; background: #FFFFFF;
				.redbor{
					.el-input__inner{border: 1px #EEF7FF solid;}
				}
				.tilte{ background: #F9F9F9; padding-left: 30px; line-height: 45px; font-size: 14px;
					span{ background: #B1E4FF; color: #FFFFFF; float: right; line-height: 15px; cursor: pointer; padding: 5px 0; display: block; width: 24px; text-align: center; margin-right: 20px; margin-top: 8px; border-radius: 14px;}
				}
				.w330{
          /deep/ .el-form-item__content{ width: 330px !important;}
					/deep/ .el-input__inner{ width: 330px !important;}
				}
				.w480{
					/deep/ .el-input__inner{ width: 480px !important;}
				}
				.con{ background: #FFFFFF; padding: 35px;
          .shop-title{ font-size: 18px; margin-bottom: 30px; color: #333;
            span{ font-size: 14px; margin-left: 40px;}
            .red{ color: #EEF7FF}
            .green{ color: green}
          }
          .eaea{ background: #EAEAEA; padding: 10px;}
          .el-form-item{ margin-bottom: 0;}
          .shop-time{ font-size: 14px; color: #999; border-bottom: 3px #eaeaea solid; padding-bottom: 10px;
            >span{ margin-right: 40px;}
          }
					.flex{ display: flex;}
					.ori{ background: #FBFBFB; padding: 20px 10px;
						.fx{ display: flex; position: relative; left: -10px; top: -20px; background: #FFFFFF;
							.fxli{ flex-basis: 200px; text-align: center; border-top: 3px #FFFFFF solid;  line-height: 40px; cursor: pointer;}
							.fxact{ background: #FBFBFB; border-top: 3px #EEF7FF solid;}
						}
						.fxbtm{ display: flex; padding-left: 50px;
							.red{ margin-left: 20px; color: #FF3B3B;}
						}
						.hui{ color: #999;}
						/deep/ .el-input{ width: 300px;}
						/deep/ .el-form-item{ margin-bottom: 20px;}
						/deep/ .el-form-item__label{ width: 150px !important;}
						.age .el-input{ width: 150px;}
						.wenhao2{color: #999; font-size: 14px;}
						.no{
							display: flex; align-items: center;
							#drop{
								.el-button--primary{ background: #409EFF;border: 1px #409EFF solid;}
							}
							.nonum{ background: #409EFF; padding: 0px 10px; line-height: 35px; height: 35px; color: #FFFFFF; border-radius: 3px; display: block;}
							.el-button{ }
							span{ margin: 0 20px;}
						}

					}
				}
				.haochi{
				    /deep/ .el-radio__label{ line-height: 40px;}
					/deep/ .el-select{ margin-left: 20px;}
				}
				.btm0 {
					/deep/ .el-button{ margin-left: 20px;}
					/deep/ .el-form-item{ margin-bottom: 0;}
				}
				.label200 /deep/ .el-form-item__label{ width: 149px !important;}
				.avatar-uploader /deep/ .el-upload {
					border: 1px dashed #d9d9d9;
					border-radius: 6px;
					cursor: pointer;
					position: relative;
					overflow: hidden;
				  }
				  .avatar-uploader .el-upload:hover {
					border-color: #409EFF;
				  }
				  .avatar-uploader-icon {
					font-size: 28px;
					color: #8c939d;
					width: 178px;
					height: 178px;
					line-height: 178px;
					text-align: center;
				  }
				  .avatar {
					width: 178px;
					height: 178px;
					display: block;
				  }
				.wenhao{ background: #B1E4FF; color: #FFFFFF; line-height: 15px; cursor: pointer; padding: 5px 11px; margin-left: 20px; text-align: center;  border-radius: 14px;}
			}

		}
	}
</style>
